package cn.tedu.ems.pojo.vo;

import cn.tedu.ems.pojo.entity.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserLogin implements UserDetails {

    //要封装User信息,所以给个User
    private User user;

    //获取权限
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    //获取密码
    @Override
    public String getPassword() {
        return user.getPassword();
    }

    //获取用户名
    @Override
    public String getUsername() {
        return user.getUsername();
    }

    //账号没有过期
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    //账号没有被锁定
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    //凭证没有过期
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    //用户没被禁用
    @Override
    public boolean isEnabled() {
        return true;
    }

}